
#include "../../Command.h"

#include "../../engine.h"

#include "../../User.h"
#include "../../Enum.h"

#include "../../NLogic/Static.h"
#include "../../NLogic/Battle.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_PK_OUT_REQ(User * pUser, ::Network::Packet * pPacket)
{
/*
	CS_PK_OUT_REQ		0x1413
	{

	}

	SC_PK_OUT_REQ		0x1414
	{
		s16  s16ack;
		u16 u16map_id;		/// 입장할 맵ID
		u16 u16pos_x;		/// 입장 좌표X
		u16 u16pos_y;		/// 압장 좌표Y
	}
*/

	NLogic::Space * pSpace = pUser->GetSpace();
	if( NULL == pSpace )
	{
		NLogic::NFunction::SendExceptionNoSpace(pUser);
		DEBUGLOG("%s %d userseq[%d] Space is NULL", __FUNCTION__, __LINE__, pUser->GetUserSeq());
		return;
	}

	STRESSLOG("%s", __FUNCTION__);

	PREPARE_PACKET;

	pUser->GetBattle()->GetData().bReadyFight = false;

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();

	*pAck << static_cast<uint16_t>(ACK_OK);
	*pAck << static_cast<uint16_t>(1);	// map id
	*pAck << static_cast<uint16_t>(ConstPosX);
	*pAck << static_cast<uint16_t>(ConstPosY);

	pAck->MakePacket(CMD_SC_PK_OUT_REQ);

	pUser->Send(pAck);

	pSpace->LeaveUser(pUser);
}

} /*NCommand*/ } /*ProjectZ*/

